
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using ODSWebService.Services;
using ODSearchEngine;

namespace ODSWebService
{
	public class MvcApplication : System.Web.HttpApplication
	{
		public static void RegisterRoutes (RouteCollection routes)
		{
			routes.IgnoreRoute ("{resource}.axd/{*pathInfo}");
			routes.IgnoreRoute("servicestack/{*pathInfo}");
			routes.MapRoute ("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" });			
		}

		protected void Application_Start ()
		{
			log4net.Config.XmlConfigurator.Configure();
			this.InitSearchEngine();
			this.InitServices();
			RegisterRoutes (RouteTable.Routes);			
		}
		
		private void InitSearchEngine()
		{
			IIndexEngine indexEngine = IocManager.Get<IIndexEngine>();
			indexEngine.CreateIndex(false);
			indexEngine.Init();
			ISearchEngine searchEngine = IocManager.Get<ISearchEngine>();
			searchEngine.Init();
		}
		
		private void InitServices()
		{
			new ODSServiceHost().Init();
		}
	}
}

